/*
Copyright 2020 Google LLC

Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file or at
https://developers.google.com/open-source/licenses/bsd
*/

#include "system.h"
#include "test_framework.h"

#include "basics.h"

/**
 * Sets the given buffer `p` to the value `i`, treating `p`
 * as a hash of length `hash_size(GIT_SHA1_FORMAT_ID)`.
 */
void set_test_hash(uint8_t *p, int i)
{
	memset(p, (uint8_t)i, hash_size(GIT_SHA1_FORMAT_ID));
}

/**
 * Append binary data to a strbuf.
 *
 * @param b strbuf to append to
 * @param data pointer to data to append
 * @param sz size of data to append
 * @return number of bytes appended
 */
ssize_t strbuf_add_void(void *b, const void *data, size_t sz)
{
	strbuf_add(b, data, sz);
	return sz;
}
